$(document).ready(function(){
	initContent();
});  

function initContent(){
	padMarketing.ajaxNormal(
			'/pad_marketing/notices/getAllList.action',
			{},
			function(data){
				var html ;
				for (var i = 0; i < data.length; i++) {
					if (data[i].PUSH_FLAG ==  '0') {
						html=html+" <tr class='active  noticec' onClick='readFlag("+data[i].PUSH_ID+",this)'>";
					}else{
						html=html+"<tr>";
					}
					html=html+" <td align='center' width='120'>";
					html=html+"<button class='btn 	btn-"+data[i].style+" btn-circle'><span class='font-20 white'>"+data[i].displayWord+"</span></button>";
					html=html+"<div class='blank-10'></div>";
					html=html+"<p class='text-center font-18'>"+data[i].displayName+"</p>";
					html=html+"</td>";
					html=html+"<td width='60%'>";
					if (data[i].PUSH_FLAG== '0') {
						strongHtml = "<span style='font-weight:bold'>"+data[i].PUSH_MESSAGE+"</span>";
					}else{
						strongHtml ="<span style='color:#a29d9d'>"+data[i].PUSH_MESSAGE+"</span>";
					}
					html=html+"<p class='font-20 lh-30'>"+strongHtml+"</p>";
					html=html+"</td>";
					if (data[i].detail == 1) {
							html=html+" <td align='center'><a onclick='javascript:void(0)' href='"+data[i].url+"url=/pad_marketing/notices/main.action' class='font-24 blue'>"+data[i].a+"</a></td>";
					}else{
						 html=html+"<td align='center'>  </td>";
					}
					html=html+"<td width='140' align='right'>"+data[i].PUSH_TIME+"</td>";
					html=html+"</tr>";
				}
				$('#content').find('table tbody').append(html);
				if (data.length >0) {
					$('#content').find('table').before(" <a class='padding-2 block underline text-right' href='#'  onclick='readAllFlag()'>全部设为已读</a>");
				}
			}
		)		
}
function readFlag(id,obj){
	if (id != null || "" != id) {
		$(obj).removeClass('active');
		$(obj).children('td').eq(1).find('span').removeAttr('style');
		$.ajax({
			url : '/pad_marketing/notices/readDone.action',
			data:{
				id:id
			},
			type : "get"
		})
	}
}

function readAllFlag(){
	$.ajax({
		url : '/pad_marketing/notices/readDone.action',
		type : "get"
	})
	location.reload();
}
